import { Body, Controller, Get, Post, Query } from '@nestjs/common';

import { DocumentService } from './document.service';
import { CreateDocumentDto } from './dto/create-document.dto';

@Controller('document')
export class DocumentController {
  constructor(private readonly documentService: DocumentService) {}

  @Post('create')
  create(@Body() createDocumentDto: CreateDocumentDto) {
    return this.documentService.create(createDocumentDto);
  }

  @Post('load')
  loadURL(@Body() createDocumentDto: CreateDocumentDto) {
    return this.documentService.load(createDocumentDto);
  }

  @Get()
  findAll(
    @Query('current') current: number,
    @Query('pageSize') pageSize: number,
    @Query('source') source: string,
  ) {
    return this.documentService.findAll(Number(current), Number(pageSize), source);
  }

  @Post('removeAll')
  removeAll() {
    return this.documentService.removeAll();
  }
}
